package com.leetcode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class P0083RemoveDuplicatesFromSortedList {

	public static void main(String[] args) {
		System.out.println(111);
		ListNode head = new ListNode(1);
		head.next = new ListNode(1);
		head.next.next = new ListNode(1);
		
		deleteDuplicates(head);
	}
	
	
	public static ListNode deleteDuplicates(ListNode head) {
        ListNode cur = head;
        if(head == null) {
        	return head;
        }
        
		while(cur != null) {
			if(cur.next != null && cur.val == cur.next.val) {
				if(cur.next.next != null) {
					cur.next = cur.next.next;
				} else {
					cur.next = null;
				}
			} else {
				cur = cur.next;
			}
		}
		
		return head;
    }


	static class ListNode{
		int val;
		ListNode next;
		ListNode(int x) { val = x; }
	}

}

